package com.acegear.horizon.domain.repository.jpa;

import com.acegear.horizon.domain.models.jpa.PostLike;

import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
import java.util.Optional;

/**
 * Created by wangsike on 2016/12/22.
 */
public interface PostLikeRepository extends PagingAndSortingRepository<PostLike, Long> {

    Integer countByPostId(Long postId);

    Integer countByUserId(Long userId);

    List<PostLike> findByUserId(Long userId, Pageable pageable);

    Optional<PostLike> findTopByUserIdAndPostId(Long userId, Long postId);

    void deleteByPostIdAndUserId(Long postId, Long userId);
}
